﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class EditProfile : PageBase
{
    protected void Page_Load( object sender, EventArgs e )
    {
        Message.Text = "";

        if ( !Page.IsPostBack )
        {
            MembershipUser user = Membership.GetUser();
            LabelNom.Text = user.UserName;
            LabelAdresseMessagerie.Text = user.Email;
        }
    }

    protected void ButtonSupprimer_Click( object sender, EventArgs args )
    {
        string[] users;
        users = Roles.GetUsersInRole( "Administrateur" );
        if ( users.Length == 1 )
        {
            Message.Text = Resources.labels.SupprimeProfileButtonSupprimerLastAdmin;
            //Message.Text = "<br>Vous êtes le dernier \"Administrateur\" de cette application.<br>"
            //    + "Vous ne pouvez pas vous supprimer.<br>";
            return;
        }

        MembershipUser user = Membership.GetUser();
        try
        {
            Membership.DeleteUser( user.UserName, true );
        }
        catch ( Exception e )
        {
            Message.Text = e.Message.ToString();
        }

        Message.Text = Resources.labels.SupprimeProfileButtonSupprimerUserDeletedSuccess;
        //Message.Text = "Votre compte a été supprimé.<br>";
        FormsAuthentication.SignOut();
    }
}

